<template>
	<view class="remove_tabbar content">
		<!-- 底部tabbar -->
		<Tabbar :current-page="currentPage"></Tabbar>
	</view>
</template>

<script>
	import Tabbar from '@/compontents/Tabbar.vue';
	import {
		getMemberInfo,
		memberNumber,
		register,
		getRegisterByNow,
	} from '@/api.js';
	export default {
		components: {
			Tabbar,
		},
		data() {
			return {
				currentPage: 'my',
				userInfo: {},
				number: {},
				alreadyCheckIn: false,
			};
		},
		onShow() {
			this.init();
		},
		onLoad(options) {
			uni.$on('refreshData', () => {
				console.log('返回了');
				this.init();
			});
		},
		methods: {
			goAuthentication() {
				uni.navigateTo({
					url: '/pages/my/authentication',
				});
			},
			init() {
				this.getUserInfo();
				this.getMemberNumber();
				this.RegisterByNow();
			},
			async RegisterByNow() {
				let res = await getRegisterByNow();
				console.log('是否签到', res.result);
				this.alreadyCheckIn = res.result;
			},

			goRecord() {
				uni.navigateTo({
					url: '/pages/shop/exchangeRecords',
				});
			},

			goposts() {
				uni.navigateTo({
					url: '/pages/my/posts',
				});
			},
			goEdit() {
				uni.navigateTo({
					url: '/pages/my/editUser',
				});
			},
			myfollow() {
				uni.navigateTo({
					url: '/pages/my/myFollowList',
				});
			},
			follow() {
				uni.navigateTo({
					url: '/pages/my/followList',
				});
			},
			goWallet() {
				uni.navigateTo({
					url: '/pages/my/wallet',
				});
			},
			gofeedback() {
				uni.navigateTo({
					url: '/pages/my/feedback',
				});
			},
			bindphone() {
				uni.navigateTo({
					url: '/pages/my/bindphone',
				});
			},
			goprivacy() {
				uni.navigateTo({
					url: '/pages/my/privacy',
				});
			},
			async registerClick() {
				if (this.alreadyCheckIn) {
					return;
				}
				let res = await register();
				if (res.code == 200) {
					uni.showToast({
						icon: 'none',
						title: '签到成功',
					});
					this.getUserInfo();
					this.getMemberNumber();
				}
			},
			async getMemberNumber() {
				let res = await memberNumber();
				this.number = res.result;
			},
			async getUserInfo() {
				let res = await getMemberInfo();
				this.userInfo = res.result;
				uni.setStorage({
					key: 'userInfo',
					data: JSON.stringify(res.result),
				});
				if (!this.userInfo.schoolId || this.userInfo.schoolId == '') {
					uni.reLaunch({
						url: '/pages/login/chooseSchool',
					});
				}
			},
			goPointsMall() {
				uni.navigateTo({
					url: '/pages/shop/pointsShop',
				});
			},
			goPointsList() {
				uni.navigateTo({
					url: '/pages/my/pointsMall',
				});
			},
		},
	};
</script>

<style lang="scss">
	.user_info {
		padding-top: 20rpx;

		.aravat_box {
			background: #fff;
			width: 126rpx;
			height: 126rpx;
			border-radius: 50% 50%;
			overflow: hidden;
			margin-left: 20rpx;
			margin-right: 24rpx;

			.aravat {
				width: 126rpx;
				height: 126rpx;
			}
		}

		.nike_name {
			font-family: PingFang SC, PingFang SC;
			font-weight: bold;
			font-size: 34rpx;
			color: #000000;
		}

		.live {
			width: 50rpx;
		}

		.qiandao {
			width: 146rpx;
			height: 60rpx;
			line-height: 60rpx;
			text-align: center;
			background: #f6d44d;
			border-radius: 48rpx 48rpx 48rpx 48rpx;
			font-family: PingFang SC, PingFang SC;
			font-weight: 500;
			font-size: 24rpx;
			color: #ffffff;
			margin-top: 18rpx;
		}

		.readyqiandao {
			width: 146rpx;
			height: 60rpx;
			line-height: 60rpx;
			text-align: center;
			background: rgba(218, 255, 240, 0.6);
			color: rgba(0, 199, 119, 0.6);
			border-radius: 48rpx 48rpx 48rpx 48rpx;
			font-family: PingFang SC, PingFang SC;
			font-weight: 500;
			font-size: 24rpx;
			margin-top: 18rpx;
		}

		.ID {
			padding: 6rpx 20rpx;
			height: 46rpx;
			background: #fafdf9;
			border-radius: 23rpx 23rpx 23rpx 23rpx;
			text-align: center;
			line-height: 46rpx;
			font-family: PingFang SC, PingFang SC;
			font-weight: 500;
			font-size: 24rpx;
			color: #5faf85;
			margin-top: 14rpx;
		}

		.edit {
			font-family: PingFang SC, PingFang SC;
			font-weight: 500;
			font-size: 24rpx;
			color: #747474;
		}

		.right {
			width: 12rpx;
			margin-left: 16rpx;
		}

		.vip_box {
			width: 690rpx;
			height: 120rpx;
			background: #f6d44d;
			border-radius: 23rpx 23rpx 23rpx 23rpx;
			padding: 22rpx 30rpx;
			box-sizing: border-box;

			.vip_title {
				font-family: PingFang SC, PingFang SC;
				font-weight: bold;
				font-size: 32rpx;
				color: #ffffff;
			}

			.vip {
				width: 72rpx;
			}

			.vip_tips {
				font-family: PingFang SC, PingFang SC;
				font-weight: bold;
				font-size: 22rpx;
				color: #ffffff;
			}

			.next {
				width: 146rpx;
				height: 50rpx;
				line-height: 50rpx;
				text-align: center;
				background: #ffffff;
				border-radius: 26rpx 26rpx 26rpx 26rpx;
				font-family: PingFang SC, PingFang SC;
				font-weight: 500;
				font-size: 24rpx;
				color: #7a7a7a;
			}
		}

		.data_li {
			width: calc(690rpx / 5);
			text-align: center;

			.num {
				font-family: PingFang SC, PingFang SC;
				font-weight: 500;
				font-size: 24rpx;
				color: #000000;
				width: calc(690rpx / 4);
			}

			.name {
				font-family: PingFang SC, PingFang SC;
				font-weight: 500;
				font-size: 24rpx;
				color: #000000;
				width: calc(690rpx / 4);
			}
		}
	}

	.function {
		background: #f5f7fb;
		width: 750rpx;
		padding: 16rpx 30rpx;
		box-sizing: border-box;

		.function_box {
			border-radius: 14rpx 14rpx 14rpx 14rpx;
			background: #fff;
			margin-bottom: 20rpx;

			.function_li {
				padding: 30rpx 0;
				margin: 0 30rpx;
				border-bottom: 1rpx solid #dadada;

				.logo_img {
					width: 34rpx;
				}

				.logo_name {
					font-family: PingFang SC, PingFang SC;
					font-weight: 500;
					font-size: 32rpx;
					color: #000000;
					margin-left: 8rpx;
				}

				.logo_right {
					width: 12rpx;
				}
			}
		}
	}

	.mr54 {
		margin-right: 54rpx;
	}

	.mt54 {
		margin-top: 54rpx;
	}

	.mb40 {
		margin-bottom: 40rpx;
	}

	.mb30 {
		margin-bottom: 30rpx;
	}

	.border-none {
		border: none !important;
	}
</style>
